<?php

	function	do_etat($str)
	{
		switch($str) 
		{
			case 'e':
			return "En cours ...";
			break;
			case 'v':
			return "En cours ...";
			break;
			case 'r': 
			return "Refus&eacute;e.";
			break;
			case 'l':
			return "Livrée !";
			break;
			case 'c':
			return "En cours ...";
			break;
			case 'p':
			return "A cours ...";	
			break;
			case 's':
			return "A livrer...";
			break;
			case 'd':
			return "En livraison...";
			break;
		  }
	}
	function	do_etat_offre($str)
	{
		switch($str) 
		{
			case 'P':
			return "Propos&eacute;e";
			break;
			case 'A':
			return "Accept&eacute;e";
			break;
			case 'R': 
			return "Refus&eacute;e.";
			break;
		}
	}
	
	if (isset($_GET['do']) && isset($_GET['idcom']) && $_GET['do'] == 'delete') 
	{
		$sql = new db();
		$req = "DELETE FROM offre_transport WHERE GLN_Transporteur=".$_SESSION['login']." AND Id_Commande=".$_GET['idcom'];
		$sql->query($req);
	}
		
		$sql = new db();
		$req = "SELECT co.*,  pra.Prix, pre.Date_fin, of.Prix_offre, of.Etat AS Statut FROM proposition_affretement AS pra, commande AS co, offre_transport AS of, preparation AS pre WHERE of.Id_Commande = co.Id_Commande AND co.Id_Commande = pra.Id_Commande AND of.GLN_Transporteur =".$_SESSION['login']." AND pre.Id_Commande = of.Id_Commande";
		$sql->query($req);
		if ($sql->num_rows() > 0)
		{
			$array = array();
			while ($tmp = $sql->fetch_array())
			{
				$tmp['Etat'] = do_etat($tmp['Etat']);
				$tmp['Statut'] = do_etat_offre($tmp['Statut']);
				$array[] = $tmp;
			}
		}
?>